package com.example.springhelloworld.mapper;

import com.example.springhelloworld.pojo.Student;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;


public interface StudentAnnoDao {
    /*根据查询用户*/
    @Select("SELECT id,user_id,course_id,score,student_name FROM student_score where id = #{id}")
    Student queryById(int id);

    /*根据姓名模糊查询*/
    @Select("SELECT id,user_id,course_id,score,student_name\n" +
            "        FROM `student_score`\n" +
            "        where student_name like concat('%',#{student_name},'%')")
    Student queryByName(String name);

    /*添加学生*/
    @Insert("  insert into student_score values (id=#{id},user_id=#{user_id},course_id=#{course_id},\n" +
            "                    score=#{score},student_name=#{student_name})")
    int addUser(Student student);

    /*修改学生*/
@Update(" update student_score set user_id= 8 where id=#{id}")
    int updateStudent(int id);

    /*删除学生*/
    @Delete(" delete from student_score where id=#{id}")
    int deleteStudent(int id);
}
